<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class whitelistMiddleware
{
  public function handle(Request $request, Closure $next)
  {
    $ips = auth()->user()->whitelist->pluck('ip');
    if ($ips->count() === 0 || $ips->contains($request->getClientIp())) {
      return $next($request);
    }
  }
}
